// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   PresentShow.java

package com.kaylyn.item;

import com.kaylyn.util.Initializable;
import com.kaylyn.util.Resource;
import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class PresentShow extends JLabel implements Initializable {

	public PresentShow() {
		setSize(840, 560);
		setIcon(new ImageIcon(Resource
				.loadImage("Fresh_green_leaves_da035011e.jpg")));
		setOpaque(true);
		scrollPane = new JScrollPane();
		scrollPane.getViewport().setLayout(null);
		scrollPane.setSize(700, 100);
		scrollPane.setLocation(70, 400);
		scrollPane.setOpaque(false);
		scrollPane.getViewport().setOpaque(false);
		scrollPane.setBorder(BorderFactory.createEmptyBorder());
		scrollPane.setVerticalScrollBarPolicy(21);
		scrollPane.setHorizontalScrollBarPolicy(31);
		content = new JLabel();
		content.setSize(125 * imagefile.length, 100);
		content.setLocation(0, 0);
		content.setLayout(null);
		icon = new ImageIcon[imagefile.length];
		iconLabel = new JLabel[imagefile.length];

		for (int i = 0; i < imagefile.length; i++) {
			icon[i] = new ImageIcon(Resource.loadImage(iconfile[i] + ".jpg"));
			iconLabel[i] = new JLabel();
			iconLabel[i].setIcon(icon[i]);
			iconLabel[i].setSize(100, 77);
			iconLabel[i].setLocation(125 * i, 13);
			content.add(iconLabel[i]);
			final int j = i;
			iconLabel[i].addMouseListener(new MouseAdapter() {

				public void mouseEntered(MouseEvent e) {
					iconLabel[j].setBorder(BorderFactory.createLineBorder(
							Color.WHITE, 3));
				}

				public void mouseExited(MouseEvent e) {
					iconLabel[j].setBorder(BorderFactory.createEmptyBorder());
				}

				public void mouseReleased(MouseEvent e) {
					showLabel.setIcon(new ImageIcon(Resource
							.loadImage((new StringBuilder(String
									.valueOf(imagefile[j]))).append(".jpg")
									.toString())));
				}

			});

		}

		showLabel = new JLabel();
		showLabel.setOpaque(true);
		showLabel.setSize(450, 350);
		showLabel.setLocation(195, 25);
		showLabel.setBorder(BorderFactory.createRaisedBevelBorder());
		add(showLabel);
		add(scrollPane);
		showLabel.setIcon(new ImageIcon(Resource.loadImage((new StringBuilder(
				String.valueOf(imagefile[0]))).append(".jpg").toString())));
	}

	public void start() {
		scrollPane.getViewport().setView(content);
		Runnable r = new Runnable() {

			@Override
			public void run() {
				while (flag) {
					position.x += 1;
					if (position.x % 125 == 0) {
						index %= iconLabel.length;
						Dimension size = content.getSize();
						content.setSize(size.width + 125, size.height);
						iconLabel[index].setLocation(size.width, 13);
						index++;
					}
					SwingUtilities.invokeLater(new Runnable() {

						@Override
						public void run() {
							scrollPane.getViewport().setViewPosition(position);
						}
					});

					try {
						Thread.sleep(16);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
			}
		};
		new Thread(r).start();

	}

	public void stop() {
		flag = false;
	}

	private static final long serialVersionUID = 1L;
	private JScrollPane scrollPane;
	private ImageIcon icon[];
	private String iconfile[] = { "0s1", "0s2", "0s3", "0s4", "0s5", "0s6",
			"0s7", "0s8", "0s9", "0s10", "0s11", "0s12", "0s13", "0s14",
			"0s15", "0s16", "0s17", "0q1", "0q2", "0q3", "0q4", "0q5", "0q6",
			"0q7", "0q8", "0q9", "0q12", "0q13", "0q14", "0q15", "0q16",
			"0q17", "0q18", "0q19", "0q20" };
	private String imagefile[] = { "s1", "s2", "s3", "s4", "s5", "s6", "s7",
			"s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17",
			"q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9", "q12", "q13",
			"q14", "q15", "q16", "q17", "q18", "q19", "q20" };
	private JLabel content;
	private JLabel showLabel;
	private JLabel iconLabel[];
	private boolean flag = true;
	private Point position = new Point(0, 0);
	int index = 0;
}
